using BookingSystem.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BookingSystem.Mappings
{
    [TestClass]
    public class BedMapTests
    {
        [TestMethod]
        public void NewBed_Saved()
        {
            using (var session = BookingSystem.Config.CreateSessionFactory().OpenSession())
            {
                var bed = new Resource();
                session.SaveOrUpdate(bed);


                var savedBed = session.CreateCriteria(typeof(Resource)).List<Resource>();

                Assert.AreEqual(savedBed[0].Id , 1);
            }

        }

        [TestMethod]
        public void NewBed_WithRoom_Saved()
        {
            using (var session = BookingSystem.Config.CreateSessionFactory().OpenSession())
            {

                var room = new Resource();
                session.SaveOrUpdate(room);

                var bed = new Resource { Description = "Test" };
                session.SaveOrUpdate(bed);

                var resources = session.CreateCriteria(typeof(Resource)).List<Resource>();

                Assert.AreEqual(resources[0].Id, 1);
            }

        }
    }
}